import { Controller, Get, Module } from "@nestjs/common";
import configuration from "./configuration";
import { WebResult } from "./web.result";

@Controller("configuration")
class ConfigurationController {
  @Get()
  getConfiguration() {
    const c = { ...configuration };
    delete c.email;
    delete c.user;
    delete c.wechat;
    delete c.server;
    delete c.resource;
    return WebResult.success(configuration);
  }

  @Get(["/website"])
  getWebsiteConfiguration() {
    return WebResult.success(configuration.website);
  }
  @Get("/website/version")
  getWebsiteVersion(): string {
    return configuration.website.version;
  }

  @Get("/website/logo")
  getWebsiteLogo(): string {
    return configuration.website.logo;
  }

  @Get("/website/name")
  getWebsiteName(): string {
    return configuration.website.name;
  }

  @Get("/website/description")
  getWebsiteDescription(): string {
    return configuration.website.description;
  }

  @Get("/website/copyright")
  getWebsiteCopyright(): string {
    return configuration.website.copyright;
  }

  @Get(["/website/ICP", "/website/icp"])
  getWebsiteICP(): string {
    return configuration.website.ICP备案;
  }

  @Get(["/website/公网安备案", "/website/公安备案"])
  getWebsite公网安备案信息(): string {
    return configuration.website.公网安备案;
  }

  @Get(["/website/萌ICP备案号", "/website/icp_moe"])
  getWebsiteMengICP(): string {
    return configuration.website.萌ICP备案号;
  }

  @Get(["/article"])
  getArticleConfiguration() {
    return WebResult.success(configuration.article);
  }

  @Get(["/article/like"])
  getArticleLikeConfiguration() {
    return WebResult.success({
      enable: configuration.article.enableLike,
      enableLike: configuration.article.enableLike,
    });
  }
  @Get(["/article/comment"])
  getArticleCommentConfiguration() {
    return WebResult.success({
      enable: configuration.article.enableComment,
      enableComment: configuration.article.enableComment,
    });
  }

  @Get(["/twikoo"])
  getTwikooConfiguration() {
    return WebResult.success(configuration.twikoo);
  }

  @Get("/tongji/baidu")
  getBaiduTongjiConfiguration() {
    return WebResult.success(configuration.tongji?.baidu);
  }

  @Get(["/wechat/appid", "/wechat/appID", "/wx/appid", "/wx/appID"])
  getWechatAPPID(): string {
    return configuration.wechat?.appID;
  }
}

@Module({
  controllers: [ConfigurationController],
})
export class ConfigurationModule {}
